<head>
	<body>
		<form method="post">
			<p>
				姓名：
				<input type="text" name="name" id="" value="" />
			</p>

			<p>
				年龄：
				<input type="text" name="age" id="" value="" />
			</p>
			<p>
				性别：
				<select name=sex>
					<option>男</option>
					<option>女</option>
					<option>保密</option>
				</select>
			</p>
			<p>
				手机号：
				<input type="text" name="phone" id="" value="" />
			</p>
			<p>
				邮箱：
				<input type="text" name="email" id="" value="" />
			</p>
			<p>
				班级：
				<input type="text" name="class" id="" value="" />
			</p>
			<p>
				密码：
				<input type="password" name="pasword" id="" value="" />
			</p>
			<input type="submit" value="提交"/>
		</form>
	</body>
</head>
<?php
$name = $_POST["name"];
$age = $_POST["age"];
$sex = $_POST["sex"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$class = $_POST["class"];
$pasword=$_POST["pasword"];
if($name && $age && $class && $pasword){
$conn = new mysqli('127.0.0.1', 'root', '123456', 'scholl');
$sql = "insert into stu (name,age,sex,phone,email,class,pasword)values('$name',$age,'$sex','$phone','$email',$class,'$pasword')";
var_dump($sql);
$ret = $conn -> query($sql);
var_dump($ret);
echo '新增用户成功，ID=' . $conn -> insert_id;
}
?>